
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module gummworld2.toolkit</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="gummworld2.html"><font color="#ffffff">gummworld2</font></a>.toolkit</strong></big></big> (version $Id: toolkit.py 418 2013-08-19 14:38:28Z stabbingfinger@gmail.com $)</font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:///C:/cygwin/home/bw/devel/python/svn/gummworld2_devel/gamelib/gummworld2/toolkit.py">c:\cygwin\home\bw\devel\python\svn\gummworld2_devel\gamelib\gummworld2\toolkit.py</a></font></td></tr></table>
    <p><tt>toolkit.py&nbsp;-&nbsp;Some&nbsp;helper&nbsp;tools&nbsp;for&nbsp;Gummworld2.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="gummworld2.data.html">gummworld2.data</a><br>
<a href="os.html">os</a><br>
</td><td width="25%" valign=top><a href="pygame.html">pygame</a><br>
<a href="re.html">re</a><br>
</td><td width="25%" valign=top><a href="urllib.html">urllib</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
    
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="gummworld2.toolkit.html#Struct">Struct</a>
</font></dt><dt><font face="helvetica, arial"><a href="gummworld2.toolkit.html#Tilesheet">Tilesheet</a>
</font></dt></dl>
</dd>
</dl>
 <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="Struct">class <strong>Struct</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>A&nbsp;class&nbsp;with&nbsp;arbitrary&nbsp;members.&nbsp;Construct&nbsp;it&nbsp;like&nbsp;a&nbsp;dict,&nbsp;then&nbsp;access&nbsp;the<br>
keys&nbsp;as&nbsp;instance&nbsp;attributes.<br>
&nbsp;<br>
s&nbsp;=&nbsp;<a href="#Struct">Struct</a>(x=2,&nbsp;y=4)<br>
print&nbsp;s.x,s.y<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Struct-__init__"><strong>__init__</strong></a>(self, **kwargs)</dt></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="Tilesheet">class <strong>Tilesheet</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
    
<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Tilesheet-__init__"><strong>__init__</strong></a>(self, file_path, image, margin, tile_size, spacing, rects)</dt></dl>

<dl><dt><a name="Tilesheet-get_image"><strong>get_image</strong></a>(self, tile_id)</dt></dl>

<dl><dt><a name="Tilesheet-tile_info"><strong>tile_info</strong></a>(self, tile_id)</dt><dd><tt>Return&nbsp;a&nbsp;<a href="#Struct">Struct</a>&nbsp;populated&nbsp;with&nbsp;tilesheet&nbsp;info&nbsp;for&nbsp;tile_id.&nbsp;This&nbsp;info<br>
represents&nbsp;everything&nbsp;needed&nbsp;by&nbsp;the&nbsp;Tile&nbsp;class&nbsp;constructor&nbsp;in<br>
world_editor.py.<br>
&nbsp;<br>
<a href="#Struct">Struct</a>&nbsp;members:<br>
&nbsp;&nbsp;&nbsp;&nbsp;name&nbsp;:&nbsp;str;&nbsp;relative&nbsp;path&nbsp;to&nbsp;image&nbsp;file<br>
&nbsp;&nbsp;&nbsp;&nbsp;image&nbsp;:&nbsp;pygame.surface.Surface;&nbsp;the&nbsp;loaded&nbsp;image<br>
&nbsp;&nbsp;&nbsp;&nbsp;margin&nbsp;:&nbsp;Vec2d;&nbsp;size&nbsp;of&nbsp;image's&nbsp;edge&nbsp;border<br>
&nbsp;&nbsp;&nbsp;&nbsp;size&nbsp;:&nbsp;Vec2d;&nbsp;size&nbsp;of&nbsp;a&nbsp;single&nbsp;tile<br>
&nbsp;&nbsp;&nbsp;&nbsp;spacing&nbsp;:&nbsp;Vec2d;&nbsp;spacing&nbsp;between&nbsp;tiles<br>
&nbsp;&nbsp;&nbsp;&nbsp;rects&nbsp;:&nbsp;pygame.Rect;&nbsp;list&nbsp;of&nbsp;rects&nbsp;defining&nbsp;tile&nbsp;subsurfaces</tt></dd></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
    
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-X_draw_parallax_tiles"><strong>X_draw_parallax_tiles</strong></a>(layer, tiles, pax_rect, view<font color="#909090">=None</font>)</dt><dd><tt>##&nbsp;EXPERIMENTAL:&nbsp;not&nbsp;working&nbsp;quite&nbsp;right</tt></dd></dl>
 <dl><dt><a name="-draw_grid"><strong>draw_grid</strong></a>(grid_cache, layeri<font color="#909090">=0</font>, color<font color="#909090">=(0, 0, 255, 255)</font>, alpha<font color="#909090">=33</font>)</dt><dd><tt>Draw&nbsp;a&nbsp;grid&nbsp;over&nbsp;the&nbsp;camera&nbsp;view.<br>
&nbsp;<br>
The&nbsp;grid_lines&nbsp;argument&nbsp;is&nbsp;a&nbsp;list&nbsp;of&nbsp;length&nbsp;two&nbsp;containing&nbsp;a&nbsp;cached<br>
[vline,hline]&nbsp;pair.&nbsp;This&nbsp;function&nbsp;will&nbsp;initialize&nbsp;the&nbsp;contents&nbsp;if&nbsp;the<br>
starting&nbsp;values&nbsp;evaluate&nbsp;to&nbsp;False&nbsp;(e.g.&nbsp;[0,0]).<br>
&nbsp;<br>
The&nbsp;layeri&nbsp;argument&nbsp;is&nbsp;the&nbsp;map&nbsp;layer&nbsp;from&nbsp;which&nbsp;to&nbsp;get&nbsp;the&nbsp;grid&nbsp;spacing.<br>
&nbsp;<br>
The&nbsp;color&nbsp;argument&nbsp;is&nbsp;the&nbsp;desired&nbsp;grid&nbsp;color.<br>
&nbsp;<br>
The&nbsp;alpha&nbsp;argument&nbsp;is&nbsp;the&nbsp;surface&nbsp;alpha.&nbsp;If&nbsp;alpha&nbsp;is&nbsp;not&nbsp;None,&nbsp;it&nbsp;must&nbsp;be&nbsp;a<br>
valid&nbsp;value&nbsp;for&nbsp;pygame.Surface.set_alpha().<br>
&nbsp;<br>
color&nbsp;and&nbsp;alpha&nbsp;are&nbsp;only&nbsp;used&nbsp;when&nbsp;when&nbsp;creating&nbsp;the&nbsp;surfaces&nbsp;for&nbsp;the<br>
grid_lines&nbsp;list.</tt></dd></dl>
 <dl><dt><a name="-draw_labels"><strong>draw_labels</strong></a>(cache_dict, layeri<font color="#909090">=0</font>, color<font color="#909090">=(0, 0, 0, 255)</font>)</dt><dd><tt>#def&nbsp;<a href="#-draw_labels">draw_labels</a>(cache_dict,&nbsp;layeri=0,&nbsp;color=pygame.Color('black')):<br>
#&nbsp;&nbsp;&nbsp;&nbsp;global&nbsp;label_font<br>
#&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;label_font&nbsp;is&nbsp;None:<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;label_font&nbsp;=&nbsp;pygame.font.Font(data.filepath('font','Vera.ttf'),&nbsp;7)<br>
#&nbsp;&nbsp;&nbsp;&nbsp;lfont&nbsp;=&nbsp;label_font<br>
#&nbsp;&nbsp;&nbsp;&nbsp;#<br>
#&nbsp;&nbsp;&nbsp;&nbsp;camera&nbsp;=&nbsp;State.camera<br>
#&nbsp;&nbsp;&nbsp;&nbsp;cam_rect&nbsp;=&nbsp;State.camera.rect<br>
#&nbsp;&nbsp;&nbsp;&nbsp;blit&nbsp;=&nbsp;camera.surface.blit<br>
#&nbsp;&nbsp;&nbsp;&nbsp;left,top,width,height&nbsp;=&nbsp;cam_rect<br>
#&nbsp;&nbsp;&nbsp;&nbsp;layer&nbsp;=&nbsp;State.map.layers[layeri]<br>
#&nbsp;&nbsp;&nbsp;&nbsp;tw,th&nbsp;=&nbsp;layer.tile_width,&nbsp;layer.tile_height<br>
#&nbsp;&nbsp;&nbsp;&nbsp;x0&nbsp;=&nbsp;left&nbsp;//&nbsp;tw<br>
#&nbsp;&nbsp;&nbsp;&nbsp;y0&nbsp;=&nbsp;top&nbsp;//&nbsp;th<br>
#&nbsp;&nbsp;&nbsp;&nbsp;x1&nbsp;=&nbsp;tw&nbsp;-&nbsp;(left&nbsp;-&nbsp;x0*tw)<br>
#&nbsp;&nbsp;&nbsp;&nbsp;y1&nbsp;=&nbsp;th&nbsp;-&nbsp;(top&nbsp;-&nbsp;y0*th)<br>
###&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;x0,y0,x1,y1<br>
#&nbsp;&nbsp;&nbsp;&nbsp;#<br>
#&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;x&nbsp;in&nbsp;xrange(x1,&nbsp;width,&nbsp;layer.tile_width):<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;y&nbsp;in&nbsp;xrange(y1,&nbsp;height,&nbsp;layer.tile_height):<br>
###&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;x,y<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name&nbsp;=&nbsp;(x+tw)//tw+x0,&nbsp;(y+th)//th+y0<br>
###&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name&nbsp;=&nbsp;(x+tw)//tw,&nbsp;(y+th)//th<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;label&nbsp;=&nbsp;cache_dict.get(name,&nbsp;None)<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;label:<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;label&nbsp;=&nbsp;lfont.render(str(name),&nbsp;True,&nbsp;color)<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cache_dict[name]&nbsp;=&nbsp;label<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;blit(label,&nbsp;(x+2,y+2))</tt></dd></dl>
 <dl><dt><a name="-draw_object_array"><strong>draw_object_array</strong></a>(object_array)</dt><dd><tt>Draw&nbsp;a&nbsp;layered&nbsp;array&nbsp;of&nbsp;objects.<br>
&nbsp;<br>
For&nbsp;best&nbsp;performance:<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
def&nbsp;update(self,&nbsp;dt):<br>
&nbsp;&nbsp;&nbsp;&nbsp;self.<strong>visible_objects</strong>&nbsp;=&nbsp;toolkit.<a href="#-get_object_array">get_object_array</a>()<br>
def&nbsp;draw(self,&nbsp;dt):<br>
&nbsp;&nbsp;&nbsp;&nbsp;...<br>
&nbsp;&nbsp;&nbsp;&nbsp;toolkit.<a href="#-draw_object_array">draw_object_array</a>(self.<strong>visible_objects</strong>)</tt></dd></dl>
 <dl><dt><a name="-draw_parallax_tile_range"><strong>draw_parallax_tile_range</strong></a>(layer, tile_range, pax_rect)</dt><dd><tt>##&nbsp;EXPERIMENTAL:&nbsp;not&nbsp;working&nbsp;quite&nbsp;right</tt></dd></dl>
 <dl><dt><a name="-draw_parallax_tiles"><strong>draw_parallax_tiles</strong></a>(maps, view)</dt><dd><tt>maps&nbsp;is&nbsp;a&nbsp;list&nbsp;of&nbsp;maps<br>
&nbsp;<br>
Assumptions:<br>
&nbsp;&nbsp;&nbsp;&nbsp;1.&nbsp;Maps&nbsp;are&nbsp;in&nbsp;world&nbsp;coords.<br>
&nbsp;&nbsp;&nbsp;&nbsp;2.&nbsp;Each&nbsp;map&nbsp;has&nbsp;the&nbsp;same&nbsp;number&nbsp;of&nbsp;layers.<br>
&nbsp;&nbsp;&nbsp;&nbsp;3.&nbsp;Each&nbsp;map's&nbsp;corresponding&nbsp;layer&nbsp;has&nbsp;the&nbsp;same&nbsp;parallax&nbsp;value.<br>
&nbsp;&nbsp;&nbsp;&nbsp;4.&nbsp;Each&nbsp;map&nbsp;layer&nbsp;has&nbsp;a&nbsp;parallax&nbsp;attribute:&nbsp;tuple&nbsp;of&nbsp;length&nbsp;2.<br>
&nbsp;&nbsp;&nbsp;&nbsp;5.&nbsp;Each&nbsp;map&nbsp;layer&nbsp;has&nbsp;a&nbsp;tile_range&nbsp;attribute:&nbsp;range&nbsp;of&nbsp;visible&nbsp;tiles.</tt></dd></dl>
 <dl><dt><a name="-draw_parallax_tiles_of_layer"><strong>draw_parallax_tiles_of_layer</strong></a>(cam, map, layer, parallax<font color="#909090">=(1.0, 1.0)</font>)</dt><dd><tt>##&nbsp;EXPERIMENTAL:&nbsp;not&nbsp;working&nbsp;quite&nbsp;right</tt></dd></dl>
 <dl><dt><a name="-draw_sprite"><strong>draw_sprite</strong></a>(s, blit_flags<font color="#909090">=0</font>)</dt><dd><tt>Draw&nbsp;a&nbsp;sprite&nbsp;on&nbsp;the&nbsp;camera's&nbsp;surface&nbsp;using&nbsp;world-to-screen&nbsp;conversion.</tt></dd></dl>
 <dl><dt><a name="-draw_tiles"><strong>draw_tiles</strong></a>()</dt><dd><tt>Draw&nbsp;visible&nbsp;tiles.<br>
&nbsp;<br>
Quick&nbsp;and&nbsp;dirty&nbsp;draw&nbsp;function,&nbsp;handles&nbsp;getting&nbsp;the&nbsp;objects&nbsp;and&nbsp;drawing<br>
them.&nbsp;This&nbsp;is&nbsp;a&nbsp;bit&nbsp;more&nbsp;expensive&nbsp;than&nbsp;getting&nbsp;tiles&nbsp;during&nbsp;the&nbsp;update<br>
cycle&nbsp;and&nbsp;reusing&nbsp;the&nbsp;<a href="__builtin__.html#object">object</a>&nbsp;array&nbsp;for&nbsp;the&nbsp;draw&nbsp;cycles.&nbsp;However,&nbsp;it&nbsp;is<br>
less&nbsp;hassle,&nbsp;and&nbsp;one&nbsp;might&nbsp;want&nbsp;to&nbsp;use&nbsp;this&nbsp;tactic&nbsp;if&nbsp;panning&nbsp;more&nbsp;than<br>
one&nbsp;tile&nbsp;span&nbsp;per&nbsp;tick.</tt></dd></dl>
 <dl><dt><a name="-draw_tiles_of_layer"><strong>draw_tiles_of_layer</strong></a>(layeri, pallax_factor_x<font color="#909090">=1.0</font>, pallax_factor_y<font color="#909090">=1.0</font>)</dt><dd><tt>Draw&nbsp;visible&nbsp;tiles.<br>
&nbsp;<br>
This&nbsp;function&nbsp;assumes&nbsp;that&nbsp;the&nbsp;tiles&nbsp;stored&nbsp;in&nbsp;the&nbsp;map&nbsp;are&nbsp;sprites.</tt></dd></dl>
 <dl><dt><a name="-export_world"><strong>export_world</strong></a>(fh, entities)</dt><dd><tt>A&nbsp;sequence-to-text&nbsp;exporter.<br>
&nbsp;<br>
This&nbsp;function&nbsp;is&nbsp;required&nbsp;by&nbsp;world_editor.py,&nbsp;and&nbsp;possibly&nbsp;other&nbsp;scripts,&nbsp;to<br>
export&nbsp;entities&nbsp;to&nbsp;a&nbsp;text&nbsp;file.<br>
&nbsp;<br>
Geometry&nbsp;classes&nbsp;used&nbsp;by&nbsp;this&nbsp;plugin&nbsp;are:&nbsp;RectGeometry,&nbsp;CircleGeometry,&nbsp;and<br>
PolyGeometry.<br>
&nbsp;<br>
The&nbsp;values&nbsp;saved&nbsp;are&nbsp;those&nbsp;needed&nbsp;for&nbsp;each&nbsp;shape-class's&nbsp;constructor,&nbsp;plus&nbsp;a<br>
block&nbsp;of&nbsp;arbitrary&nbsp;user&nbsp;data.&nbsp;The&nbsp;user&nbsp;data&nbsp;is&nbsp;url-encoded.</tt></dd></dl>
 <dl><dt><a name="-get_object_array"><strong>get_object_array</strong></a>(max_speed<font color="#909090">=10</font>)</dt><dd><tt>Return&nbsp;a&nbsp;list&nbsp;of&nbsp;the&nbsp;map's&nbsp;objects&nbsp;that&nbsp;would&nbsp;be&nbsp;visible&nbsp;to&nbsp;the&nbsp;camera.<br>
Operates&nbsp;on&nbsp;State.map&nbsp;and&nbsp;State.camera.<br>
&nbsp;<br>
The&nbsp;max_speed&nbsp;argument&nbsp;adds&nbsp;this&nbsp;many&nbsp;pixels&nbsp;to&nbsp;each&nbsp;edge&nbsp;of&nbsp;the&nbsp;query&nbsp;rect<br>
to&nbsp;accommodate&nbsp;for&nbsp;the&nbsp;space&nbsp;moved&nbsp;during&nbsp;frame&nbsp;interpolation&nbsp;cycles.&nbsp;This<br>
should&nbsp;at&nbsp;least&nbsp;match&nbsp;the&nbsp;scrolling&nbsp;speed&nbsp;to&nbsp;avoid&nbsp;black&nbsp;flickers&nbsp;at&nbsp;the<br>
screen&nbsp;edges.<br>
&nbsp;<br>
The&nbsp;return&nbsp;value&nbsp;is&nbsp;a&nbsp;list&nbsp;of&nbsp;<a href="__builtin__.html#object">object</a>&nbsp;lists:<br>
&nbsp;&nbsp;&nbsp;&nbsp;[&nbsp;&nbsp;&nbsp;[obj0,&nbsp;obj1,&nbsp;...],&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;layer0<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[obj0,&nbsp;obj1,&nbsp;...],&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;layer1<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;layerN<br>
&nbsp;&nbsp;&nbsp;&nbsp;]</tt></dd></dl>
 <dl><dt><a name="-get_objects_in_cell_ids"><strong>get_objects_in_cell_ids</strong></a>(map_, cell_ids_per_layer)</dt><dd><tt>Return&nbsp;a&nbsp;list&nbsp;of&nbsp;objects&nbsp;per&nbsp;layer&nbsp;for&nbsp;the&nbsp;specified&nbsp;cell&nbsp;IDs.<br>
This&nbsp;function&nbsp;is&nbsp;mainly&nbsp;for&nbsp;SuperMap,&nbsp;which&nbsp;needs&nbsp;to&nbsp;specify&nbsp;the&nbsp;map.<br>
&nbsp;<br>
The&nbsp;argument&nbsp;cell_ids_per_layer&nbsp;is&nbsp;a&nbsp;list&nbsp;of&nbsp;nested&nbsp;lists&nbsp;containing<br>
cell&nbsp;IDs:<br>
&nbsp;&nbsp;&nbsp;&nbsp;[&nbsp;&nbsp;&nbsp;[cell_id0,&nbsp;cell_id1,&nbsp;...],&nbsp;&nbsp;#&nbsp;layer0<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[cell_id0,&nbsp;cell_id1,&nbsp;...],&nbsp;&nbsp;#&nbsp;layer1<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;layerN<br>
&nbsp;&nbsp;&nbsp;&nbsp;]<br>
&nbsp;<br>
The&nbsp;return&nbsp;value&nbsp;is&nbsp;a&nbsp;similary&nbsp;constructed&nbsp;list&nbsp;of&nbsp;<a href="__builtin__.html#object">object</a>&nbsp;lists:<br>
&nbsp;&nbsp;&nbsp;&nbsp;[&nbsp;&nbsp;&nbsp;[obj0,&nbsp;obj1,&nbsp;...],&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;layer0<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[obj0,&nbsp;obj1,&nbsp;...],&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;layer1<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;layerN<br>
&nbsp;&nbsp;&nbsp;&nbsp;]</tt></dd></dl>
 <dl><dt><a name="-get_parallax_tile_range"><strong>get_parallax_tile_range</strong></a>(cam, map, layer, parallax, orig<font color="#909090">='center'</font>)</dt><dd><tt>##&nbsp;EXPERIMENTAL:&nbsp;not&nbsp;working&nbsp;quite&nbsp;right<br>
#def&nbsp;<a href="#-get_parallax_tile_range">get_parallax_tile_range</a>(cam,&nbsp;map,&nbsp;layer,&nbsp;parallax,&nbsp;orig='bottomleft'):</tt></dd></dl>
 <dl><dt><a name="-get_tilesheet_info"><strong>get_tilesheet_info</strong></a>(tilesheet_path)</dt><dd><tt>Get&nbsp;the&nbsp;tilesheet&nbsp;meta&nbsp;data&nbsp;from&nbsp;file&nbsp;if&nbsp;it&nbsp;exists.</tt></dd></dl>
 <dl><dt><a name="-get_visible_cell_ids"><strong>get_visible_cell_ids</strong></a>(camera, map_, max_speed<font color="#909090">=10</font>)</dt><dd><tt>Return&nbsp;a&nbsp;list&nbsp;of&nbsp;the&nbsp;map's&nbsp;cell&nbsp;IDs&nbsp;that&nbsp;would&nbsp;be&nbsp;visible&nbsp;to&nbsp;the&nbsp;camera.<br>
This&nbsp;function&nbsp;is&nbsp;mainly&nbsp;for&nbsp;SuperMap,&nbsp;which&nbsp;needs&nbsp;to&nbsp;specify&nbsp;the&nbsp;map.<br>
&nbsp;<br>
The&nbsp;camera&nbsp;argument&nbsp;is&nbsp;the&nbsp;camera&nbsp;that&nbsp;defines&nbsp;the&nbsp;view.<br>
&nbsp;<br>
The&nbsp;map_&nbsp;argument&nbsp;is&nbsp;the&nbsp;BasicMap&nbsp;or&nbsp;TiledMap&nbsp;to&nbsp;query.<br>
&nbsp;<br>
The&nbsp;max_speed&nbsp;argument&nbsp;adds&nbsp;this&nbsp;many&nbsp;pixels&nbsp;to&nbsp;each&nbsp;edge&nbsp;of&nbsp;the&nbsp;query&nbsp;rect<br>
to&nbsp;accommodate&nbsp;for&nbsp;the&nbsp;space&nbsp;moved&nbsp;during&nbsp;frame&nbsp;interpolation&nbsp;cycles.&nbsp;This<br>
should&nbsp;at&nbsp;least&nbsp;match&nbsp;the&nbsp;scrolling&nbsp;speed&nbsp;to&nbsp;avoid&nbsp;black&nbsp;flickers&nbsp;at&nbsp;the<br>
screen&nbsp;edge.<br>
&nbsp;<br>
The&nbsp;return&nbsp;value&nbsp;is&nbsp;a&nbsp;list&nbsp;of&nbsp;cell&nbsp;IDs&nbsp;in&nbsp;the&nbsp;map's&nbsp;spatialhash&nbsp;for&nbsp;each<br>
layer.&nbsp;The&nbsp;per-layer&nbsp;values&nbsp;are&nbsp;necessary&nbsp;because&nbsp;maps&nbsp;can&nbsp;have&nbsp;layers&nbsp;with<br>
different&nbsp;tile&nbsp;sizes,&nbsp;and&nbsp;therefore&nbsp;different&nbsp;grids.<br>
&nbsp;<br>
The&nbsp;return&nbsp;value&nbsp;is&nbsp;suitable&nbsp;for&nbsp;passing&nbsp;to&nbsp;<a href="#-get_objects_in_cell_ids">get_objects_in_cell_ids</a>().<br>
&nbsp;<br>
Returns:<br>
&nbsp;&nbsp;&nbsp;&nbsp;[&nbsp;&nbsp;&nbsp;[cell_id0,&nbsp;cell_id1,&nbsp;...],&nbsp;&nbsp;#&nbsp;layer0<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[cell_id0,&nbsp;cell_id1,&nbsp;...],&nbsp;&nbsp;#&nbsp;layer1<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;layerN<br>
&nbsp;&nbsp;&nbsp;&nbsp;]</tt></dd></dl>
 <dl><dt><a name="-import_world"><strong>import_world</strong></a>(fh, rect_cls<font color="#909090">=&lt;class 'gummworld2.geometry.RectGeometry'&gt;</font>, line_cls<font color="#909090">=&lt;class 'gummworld2.geometry.LineGeometry'&gt;</font>, poly_cls<font color="#909090">=&lt;class 'gummworld2.geometry.PolyGeometry'&gt;</font>, circle_cls<font color="#909090">=&lt;class 'gummworld2.geometry.CircleGeometry'&gt;</font>)</dt><dd><tt>A&nbsp;world&nbsp;entity&nbsp;importer.<br>
&nbsp;<br>
This&nbsp;function&nbsp;is&nbsp;required&nbsp;by&nbsp;world_editor.py,&nbsp;and&nbsp;possibly&nbsp;other&nbsp;scripts,&nbsp;to<br>
import&nbsp;world&nbsp;entities&nbsp;from&nbsp;a&nbsp;text&nbsp;file.&nbsp;It&nbsp;understands&nbsp;the&nbsp;format&nbsp;of&nbsp;files<br>
created&nbsp;by&nbsp;<a href="#-export_world">export_world</a>().<br>
&nbsp;<br>
Geometry&nbsp;classes&nbsp;used&nbsp;by&nbsp;this&nbsp;function&nbsp;to&nbsp;create&nbsp;shape&nbsp;objects&nbsp;are&nbsp;specified<br>
by&nbsp;the&nbsp;rect_cls,&nbsp;line_cls,&nbsp;poly_cls,&nbsp;and&nbsp;circle_cls&nbsp;arguments.&nbsp;The<br>
constructor&nbsp;parameters&nbsp;must&nbsp;have&nbsp;the&nbsp;same&nbsp;signature&nbsp;as&nbsp;geometry.RectGeometry,<br>
et&nbsp;al.<br>
&nbsp;<br>
The&nbsp;values&nbsp;imported&nbsp;are&nbsp;those&nbsp;needed&nbsp;for&nbsp;each&nbsp;shape-class's&nbsp;constructor,<br>
plus&nbsp;a&nbsp;block&nbsp;of&nbsp;arbitrary&nbsp;user&nbsp;data&nbsp;which&nbsp;will&nbsp;be&nbsp;placed&nbsp;in&nbsp;the&nbsp;shape<br>
instance's&nbsp;user_data&nbsp;attribute.<br>
&nbsp;<br>
The&nbsp;user_data&nbsp;is&nbsp;also&nbsp;parsed&nbsp;for&nbsp;tilesheet&nbsp;info.&nbsp;Tilesets&nbsp;are&nbsp;loaded&nbsp;and<br>
returned&nbsp;as&nbsp;a&nbsp;dict&nbsp;of&nbsp;toolkit.<a href="#Tilesheet">Tilesheet</a>,&nbsp;keyed&nbsp;by&nbsp;relative&nbsp;path&nbsp;to&nbsp;the<br>
image&nbsp;file.</tt></dd></dl>
 <dl><dt><a name="-interpolated_step"><strong>interpolated_step</strong></a>(pos, step, interp)</dt><dd><tt>Returns&nbsp;(float,float).<br>
&nbsp;<br>
This&nbsp;is&nbsp;a&nbsp;utility&nbsp;for&nbsp;drawing&nbsp;routines,&nbsp;after&nbsp;pos&nbsp;has&nbsp;been&nbsp;updated&nbsp;by&nbsp;step.<br>
For&nbsp;example:<br>
&nbsp;&nbsp;&nbsp;&nbsp;def&nbsp;update():<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;move_camera()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;State.camera.update()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sprite_group.update()&nbsp;&nbsp;#&nbsp;e.g.&nbsp;steps&nbsp;a&nbsp;sprite&nbsp;position<br>
&nbsp;&nbsp;&nbsp;&nbsp;def&nbsp;draw():<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;interp&nbsp;=&nbsp;State.camera.interpolate()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;camera_pos&nbsp;=&nbsp;State.camera.rect.topleft<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;s&nbsp;in&nbsp;sprite_group:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sprite_pos&nbsp;=&nbsp;Vec2d(s.rect.topleft)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pos&nbsp;=&nbsp;sprite_pos&nbsp;-&nbsp;camera_pos<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;step&nbsp;=&nbsp;s.step<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;interp_pos&nbsp;=&nbsp;toolkit.<a href="#-interpolated_step">interpolated_step</a>(pos,&nbsp;step,&nbsp;interp)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;surf.blit(s.image,&nbsp;interp_pos)</tt></dd></dl>
 <dl><dt><a name="-load_entities"><strong>load_entities</strong></a>(filepath, cls_dict<font color="#909090">={}</font>)</dt><dd><tt>Load&nbsp;entities&nbsp;via&nbsp;<a href="#-import_world">import_world</a>()&nbsp;plugin.<br>
&nbsp;<br>
The&nbsp;cls_dict&nbsp;argument&nbsp;is&nbsp;a&nbsp;dict&nbsp;of&nbsp;classes&nbsp;to&nbsp;construct&nbsp;when&nbsp;encountering<br>
shape&nbsp;data.&nbsp;The&nbsp;following&nbsp;keys&nbsp;are&nbsp;supported:&nbsp;'rect_cls',&nbsp;'line_cls',<br>
'poly_cls',&nbsp;'circle_cls'.&nbsp;If&nbsp;any&nbsp;of&nbsp;those&nbsp;keys&nbsp;are&nbsp;missing&nbsp;from&nbsp;cls_dict,<br>
the&nbsp;following&nbsp;classes&nbsp;will&nbsp;be&nbsp;used&nbsp;by&nbsp;default:&nbsp;geometry.RectGeometry,<br>
geometry.LineGeometry,&nbsp;geometry.PolyGeometry,&nbsp;geometry.CircleGeometry.<br>
Classes&nbsp;substituted&nbsp;in&nbsp;this&nbsp;manner&nbsp;must&nbsp;have&nbsp;constructors&nbsp;that&nbsp;are<br>
compatible&nbsp;with&nbsp;the&nbsp;default&nbsp;classes.</tt></dd></dl>
 <dl><dt><a name="-load_tilesheet"><strong>load_tilesheet</strong></a>(file_path)</dt><dd><tt>Load&nbsp;a&nbsp;tilesheet.&nbsp;A&nbsp;toolkit.<a href="#Tilesheet">Tilesheet</a>&nbsp;containing&nbsp;tilesheet&nbsp;info&nbsp;is<br>
returned.<br>
&nbsp;<br>
The&nbsp;file_path&nbsp;argument&nbsp;is&nbsp;the&nbsp;path&nbsp;to&nbsp;the&nbsp;image&nbsp;file.&nbsp;If&nbsp;file_path&nbsp;is&nbsp;a<br>
relative&nbsp;path,&nbsp;it&nbsp;must&nbsp;exist&nbsp;relative&nbsp;to&nbsp;data.data_dir&nbsp;(see&nbsp;the<br>
gummworld2.data&nbsp;module).&nbsp;If&nbsp;file_path.tilesheet&nbsp;exists&nbsp;it&nbsp;will&nbsp;be&nbsp;used&nbsp;to<br>
size&nbsp;the&nbsp;tiles;&nbsp;otherwise&nbsp;the&nbsp;defaults&nbsp;(0,0,32,32,0,0)&nbsp;will&nbsp;be&nbsp;used.</tt></dd></dl>
 <dl><dt><a name="-make_hud"><strong>make_hud</strong></a>(caption<font color="#909090">=None</font>, visible<font color="#909090">=True</font>)</dt><dd><tt>Create&nbsp;a&nbsp;HUD&nbsp;with&nbsp;dynamic&nbsp;items.&nbsp;This&nbsp;creates&nbsp;a&nbsp;default&nbsp;hud&nbsp;to&nbsp;serve<br>
both&nbsp;as&nbsp;an&nbsp;example,&nbsp;and&nbsp;for&nbsp;an&nbsp;early&nbsp;design&nbsp;and&nbsp;debugging&nbsp;convenience.</tt></dd></dl>
 <dl><dt><a name="-make_tiles"><strong>make_tiles</strong></a>(label<font color="#909090">=False</font>)</dt><dd><tt>Create&nbsp;tiles&nbsp;to&nbsp;fill&nbsp;the&nbsp;current&nbsp;map.&nbsp;This&nbsp;is&nbsp;a&nbsp;utility&nbsp;for&nbsp;easily&nbsp;making<br>
visible&nbsp;content&nbsp;to&nbsp;aid&nbsp;early&nbsp;game&nbsp;design&nbsp;or&nbsp;debugging.<br>
&nbsp;<br>
Tiles&nbsp;transition&nbsp;from&nbsp;top-left&nbsp;to&nbsp;bottom-right,&nbsp;red&nbsp;to&nbsp;blue.</tt></dd></dl>
 <dl><dt><a name="-make_tiles2"><strong>make_tiles2</strong></a>()</dt><dd><tt>Create&nbsp;tiles&nbsp;to&nbsp;fill&nbsp;the&nbsp;current&nbsp;map.&nbsp;This&nbsp;is&nbsp;a&nbsp;utility&nbsp;for&nbsp;easily&nbsp;making<br>
visible&nbsp;content&nbsp;to&nbsp;aid&nbsp;early&nbsp;game&nbsp;design&nbsp;or&nbsp;debugging.<br>
&nbsp;<br>
Tiles&nbsp;transition&nbsp;from&nbsp;top&nbsp;to&nbsp;bottom,&nbsp;light&nbsp;blue&nbsp;to&nbsp;brown.</tt></dd></dl>
 <dl><dt><a name="-put_tilesheet_info"><strong>put_tilesheet_info</strong></a>(tilesheet_path, tilesheet_values)</dt><dd><tt>Put&nbsp;the&nbsp;tilesheet&nbsp;meta&nbsp;data&nbsp;to&nbsp;file.</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
    
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>BLEND_RGBA_ADD</strong> = 6<br>
<strong>IMAGE_FILE_EXTENSIONS</strong> = ('gif', 'png', 'jpg', 'jpeg', 'bmp', 'pcx', 'tga', 'tif', 'lbm', 'pbm', 'pgm', 'xpm')<br>
<strong>RLEACCEL</strong> = 16384<br>
<strong>SRCALPHA</strong> = 65536<br>
<strong>__author__</strong> = 'Gummbum, (c) 2011-2013'<br>
<strong>__version__</strong> = '$Id: toolkit.py 418 2013-08-19 14:38:28Z stabbingfinger@gmail.com $'<br>
<strong>hud_font</strong> = &lt;pygame.font.Font object&gt;<br>
<strong>label_font</strong> = None</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#7799ee">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
    
<tr><td bgcolor="#7799ee"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%">Gummbum,&nbsp;(c)&nbsp;2011-2013</td></tr></table>
</body></html>